package com.dong.user.mapper;

import com.dong.thrift.user.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    @Select("select id,username,password,real_name as realName,mobile,email " +
            "from pe_user where id = #{id}")
    UserInfo getUserById(@Param("id") int id);
    @Select("select id,username,password,real_name as realName,mobile,email " +
            "from pe_user where username = #{username}")
    UserInfo getUserByName(@Param("username")String username );
    @Insert("insert into pe_user (username,password,real_name,mobile,email) values (#{u.username},#{u.password},#{u.realName},#{u.mobile},#{u.email})")
    void registerUser(@Param("u")UserInfo userInfo);
    @Select("select u.id,u.username,u.real_name as realName,u.mobile ,u.email ," +
            "t.info as intro ,t.star as stars "+
            "from pe_user u left join pe_teacher_info t " +
            "on u.id = t.user_id " +
            "where u.id = #{id}")
    UserInfo queryTeacherInfo(int id);
}
